<template>
  <nut-cell-group title="1号风机启停控制">
    <nut-divider/>
    <nut-cell title="启动">
      <template v-slot:link>
        <nut-button type="default" color="#1989fa" @click="setData('0001')" >
          启动
        </nut-button>
      </template>
    </nut-cell>
    <nut-divider/>
    <nut-cell title="停止">
      <template v-slot:link>
        <nut-button type="default" color="#1989fa" @click="setData('0000')" >
          停止
        </nut-button>
      </template>
    </nut-cell>
    <nut-divider/>
  </nut-cell-group>
  <nut-cell-group title="2号风机启停控制">
    <nut-divider/>
    <nut-cell title="启动">
      <template v-slot:link>
        <nut-button type="default" color="#1989fa" @click="setData('0010')" >
          启动
        </nut-button>
      </template>
    </nut-cell>
    <nut-divider/>
    <nut-cell title="停止">
      <template v-slot:link>
        <nut-button type="default" color="#1989fa" @click="setData('0000')" >
          停止
        </nut-button>
      </template>
    </nut-cell>
    <nut-divider/>
  </nut-cell-group>  
</template>
<script lang="ts" setup>
import { sendCommand } from '/@/api';
import {Toast} from '@nutui/nutui'

function setData(flag) {
  let my_data ={};
  
  my_data = {"command":"f","addr":"12","data":flag};
  
  var send_data = JSON.stringify(my_data)
  console.log(send_data)
  sendCommand(send_data)
  Toast.success('发送成功')
}
</script>
